/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package util;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 *
 * @author Rdelacruz
 */
public class FormatUtil {
    
    public static String format(String texto) {
        return texto!=null ? texto : "";
    }
    
    public static String format(Integer entero) {
        return entero!=null ? entero+"" : "";
    }
    
    public static String format(BigDecimal valor) {
        return valor!=null ? valor+"" : "";
    }
    
    public static String format(Enum valor) {
        return valor!=null ? valor.name() : "";
    }
    
    public static String format(Boolean valor) {
        return format(valor,"SI","NO");
    }
    
    public static String format(Boolean valor, String valorVerdadero, String valorFalso) {
        if(valor==null)
            return "";
        return valor ? valorVerdadero : valorFalso;
    }
    
    public static String format(Date date) {
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
        return dateFormat.format(date);
    }
    
    public static String formatFechaHora(Date date) {
        DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy HH:mm");
        return dateFormat.format(date);
    }
}
